import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '../components/layout/Layout.vue'

Vue.use(VueRouter)
const routes = [
  {
      path: '/login',
      component: () => import('../views/login/index.vue'),
      name: 'login',
      meta: { title: 'login', icon: 'login', affix: true }
  },
  {
    path: '/',
    component: Layout,
    redirect: '/projects',
    children: [
      {
        path: 'projects',
        component: () => import('../views/projects'),
        name: 'project',
        meta: { title: 'Project', icon: 'project', affix: true }
      },
      {
        path: 'project/:id/detail',
        component: () => import('../views/projects/detail'),
        name: 'project_detail',
        meta: { title: 'Project', icon: 'project', affix: true }
      },
      {
        path: 'project/:id/developer',
        component: () => import('../views/projects/developer'),
        name: 'project_developer',
        meta: { title: 'Project', icon: 'project', affix: true }
      },
      {
        path: 'profiles',
        component: () => import('../views/profile'),
        name: 'profile',
        meta: { title: 'Profile', icon: 'profile', affix: true }
      },
      {
        path: 'config',
        component: () => import('../views/config'),
        name: 'config',
        meta: { title: 'Config', icon: 'config', affix: true }
      },
      {
        path: 'namespace',
        component: () => import('../views/namespace'),
        name: 'namespace',
        meta: { title: 'Namespace', icon: 'dashboard', affix: true }
      },
      {
        path: 'namespace/:id',
        component: () => import('../views/namespace/edit.vue'),
        name: 'namespace_edit',
        meta: { title: 'Namespace', icon: 'dashboard', affix: true }
      },
      {
        path: 'discovery',
        component: () => import('../views/discovery'),
        name: 'discovery',
        meta: { title: 'Discovery', icon: 'discovery', affix: true }
      },
      {
        path: 'server',
        component: () => import('../views/server'),
        name: 'server',
        meta: { title: 'Server', icon: 'server', affix: true }
      },
      {
          path: 'metadata',
          component: () => import('../views/metadata/index.vue'),
          name: 'metadata',
          meta: { title: 'Metadata', icon: 'metadata', affix: true }
      },
      {
        path: 'metadata/edit',
        component: () => import('../views/metadata/edit.vue'),
        name: 'metadata_edit',
        meta: { title: 'Metadata', icon: 'metadata', affix: true }
      },
      {
        path: 'metadata/edit/:id',
        component: () => import('../views/metadata/edit.vue'),
        name: 'metadata_edit_id',
        meta: { title: 'Metadata', icon: 'metadata', affix: true }
      },
      {
        path: 'metadata/:id/history',
        component: () => import('../views/metadata/history.vue'),
        name: 'metadata_history',
        meta: { title: 'Metadata', icon: 'metadata', affix: true }
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
